<?php

namespace App\Jobs;

use App\Exceptions\ApiErrorException;
use App\Services\AlipayMessageService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class SendChangeOrderMessage implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $order_id;
    protected $statusSource;
    /**
     * @var mixed|string
     */
    private $status;

    public function __construct($podcast,$statusSource,$status='')
    {
        $this->order_id = $podcast;
        $this->statusSource = $statusSource;
        $this->status = $status;

    }

    /**
     * Execute the job.
     * @return void
     * @throws ApiErrorException
     */
    public function handle()
    {
        Log::Info("message开始");
        Log::Info($this->order_id);
        if($this->status){
             AlipayMessageService::sendChangeOrderLeaseMessage($this->order_id,$this->statusSource, $this->status);
        }else{
            AlipayMessageService::sendChangeOrderMessage($this->order_id,$this->statusSource);
        }
        Log::Info("message结束");
    }
}
